<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
  <h3>修改员工页面</h3>
  <form >
      <input type="text" v-model="emp.id" placeholder="ID" readonly ><br>
      <input type="text" v-model="emp.name" placeholder="员工姓名"><br>
      <input type="text"  v-model="emp.job" placeholder="员工岗位"><br>
      <input type="text" v-model="emp.sal" placeholder="员工工资"><br>
      <input type="button" value="修改" @click="update()"><br>
  </form>
<!--引入axios和vue-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.14/vue.js"></script>
  <script>
      let v = new Vue({
          el:"form",
          data:{
              emp:{id:"",name:"",job:"",sal:""}
          },
          methods:{
              update(){
                  //发起post异步请求
                  axios.post("/update",v.emp).then(function () {
                      location.href="/select.html";
                  })
              }
          },
          created:function () {
              //获取地址栏上的id值
              let id = location.search.split("=")[1];
              axios.get("/selectOne?id="+id).then(function (response) {
                  v.emp = response.data;
              })
          }
      })
  </script>

</body>
</html>